package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.ContactBasicDeptInfo;
import com.group.project.hrms.mapper.ContactBasicDeptInfoMapper;
import com.group.project.hrms.service.IContactBasicDeptInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class ContactBasicDeptInfoService implements IContactBasicDeptInfoService {

    @Autowired
    private ContactBasicDeptInfoMapper contactBasicDeptInfoMapper;

    @Override
    public int insertContactBasicDeptInfo(ContactBasicDeptInfo contactBasicDeptInfo) {
        return contactBasicDeptInfoMapper.insert(contactBasicDeptInfo);
    }

    @Override
    public int deleteContactBasicDeptInfo(ContactBasicDeptInfo contactBasicDeptInfo) {
        return contactBasicDeptInfoMapper.deleteByPrimaryKey(contactBasicDeptInfo);
    }

    @Override
    public int updateContactBasicDeptInfo(ContactBasicDeptInfo contactBasicDeptInfo) {
        return contactBasicDeptInfoMapper.updateByPrimaryKey(contactBasicDeptInfo);
    }

    @Override
    public ContactBasicDeptInfo selectOneContactBasicDeptInfo(ContactBasicDeptInfo contactBasicDeptInfo) {
        return contactBasicDeptInfoMapper.selectByPrimaryKey(contactBasicDeptInfo);
    }

    @Override
    public ContactBasicDeptInfo selectOneContactBasicDeptInfoByDeptID(Long id) {
        Example example = new Example(ContactBasicDeptInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("deptId" , id);
        return contactBasicDeptInfoMapper.selectOneByExample(example);
    }

    @Override
    public List<ContactBasicDeptInfo> selectContactBasicDeptInfoBySource(int sid) {
        Example example = new Example(ContactBasicDeptInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("deptSource" , sid);
        return contactBasicDeptInfoMapper.selectByExample(example);
    }

    @Override
    public List<ContactBasicDeptInfo> selectAllContactBasicDeptInfo() {
        return contactBasicDeptInfoMapper.selectAll();
    }
}
